var menu = new ContextMenu(map);

//自定义菜单类
function ContextMenu(map) {
    let me = this;

    //地图中添加鼠标工具MouseTool插件
    // this.mouseTool = new AMap.MouseTool(map);

    this.contextMenuPositon = null;

    let content = [];

    content.push("<div class='info context_menu'>");
    content.push("<p onclick='menu.back()'>返回</p>");
    content.push("</div>");

    //通过content自定义右键菜单内容
    this.contextMenu = new AMap.ContextMenu({isCustom: true, content: content.join('')});

    //地图绑定鼠标右击事件——弹出右键菜单
    map.on('rightclick', function (e) {
        me.contextMenu.open(map, e.lnglat);
        me.contextMenuPositon = e.lnglat; //右键菜单位置
    });
}

ContextMenu.prototype.back = function () {
    map.setZoom(8.33);
    let ln = new AMap.LngLat(107.624225, 30.211628);
    map.setCenter(ln);
};